<template>
  <div style="height: 500px">
    <f-table-plan v-bind="options"></f-table-plan>
  </div>
  <f-trace-code
    v-if="showTraceCode"
    showTitle
    :codeList="cached"
    @scan="handleScan"
    :source="options.data"></f-trace-code>
</template>
<script setup lang="ts">
import { reactive, ref } from 'vue';
import {
  renderTraceCodeColumn,
  useTraceColumn
} from '../../packages/components/traceCode/src/render';
import { http } from 'fok-ui';
const { showTraceCode, traceCodeColumn } = useTraceColumn();
const cached = ref([]);
const options = reactive({
  // 有productId才显示录入模式
  data: [
    {
      createBy: '1780807737856077824',
      createTime: '2025-01-08 17:18:21',
      updateBy: '1780807737856077824',
      updateTime: '2025-01-08 17:18:21',
      version: 0,
      delFlag: 0,
      id: '1876921373694988288',
      inboundId: '1876921373694988289',
      institutionId: '1746703246613555555',
      materialType: {
        code: '01',
        desc: '药品'
      },
      productId: '1876918381042319360',
      code: 'CPBM2025010000000661',
      name: '千里光片',
      spec: '24片/盒',
      doseType: '片剂',
      producer: '河南润弘本草制药有限公司',
      unit: 1,
      billUnit: 24,
      isSerial: false,
      encodingType: null,
      batchNo: '202501080001',
      produceDate: '2025-01-07',
      manufacturingDate: '2025-01-07 00:00:00',
      expirationDate: '2028-01-06 00:00:00',
      pkgAmount: 1,
      batchId: null,
      inQty: 100,
      costPrice: '1.7699115',
      costAmt: '176.9912',
      isTaxInvoice: true,
      taxRate: '0.13',
      taxPrice: '2',
      taxAmount: '23.01',
      totalPriceTax: '200',
      priceMode: {
        code: '3',
        desc: '库存定价'
      },
      additionRatio: '0',
      price: '2',
      sellAmt: '200',
      inspectedDeptId: null,
      inspectedBy: null,
      inspectedDate: null,
      qualityQty: null,
      problemQty: null,
      unqualifiedType: null,
      unqualifiedCause: null,
      payableAmt: null,
      paidAmt: null,
      comments: null,
      scanStatus: null,
      scanCount: null,
      isSpecialControl: false,
      isColdChain: false,
      isDismount: false,
      isBase: false,
      isCannabisDrug: false,
      unitJsonStr:
        '[{"unit_id":1876918381604356096,"unit":24,"unit_name":"盒","is_min_unit":0,"is_min_pack":1},{"unit_id":1876918381503692800,"unit":1,"unit_name":"片","is_min_unit":1,"is_min_pack":0}]',
      serialStr: null,
      billUnitStr: '4盒4片',
      unitName: '片',
      productPackS: [
        {
          unitId: '1876918381604356096',
          unit: 24,
          unitName: '盒',
          isMinUnit: false,
          isMinPack: true,
          isDoseUnit: null,
          converBaseUnit: null
        },
        {
          unitId: '1876918381503692800',
          unit: 1,
          unitName: '片',
          isMinUnit: true,
          isMinPack: false,
          isDoseUnit: null,
          converBaseUnit: null
        }
      ],
      unitId: '1876918381604356096',
      serialVOList: null
    }
  ],
  columns: [
    { title: '药品名称', field: 'name' },
    { title: '数量', field: 'billUnitStr' },
    traceCodeColumn,
    { title: '操作', field: 'xx' }
  ]
});
const handleScan = (code: string) => {
  return http.post('/spd/tracecodes/scanValid', {
    codes: '83738660006306584957',
    bizId: '1876921373694988289'
  });
};
</script>
